<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="工单号">
        <el-input v-model="queryParams.fOrderNo" placeholder="请输入工单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="工厂名称">
        <el-select v-loadmore="factoryLoad" filterable clearable v-model="queryParams.fOrgId" placeholder="请选择"
          @change="queryParams.pageNum = 1, getList()">
          <el-option v-for="(item, index) in factoryList" :key="index" :label="item.fOrgName"
            :value="item.fId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备名称">
        <el-select v-loadmore="deviceLoad" filterable clearable v-model="queryParams.fDeviceId" placeholder="请选择"
          @change="queryParams.pageNum = 1, getList()">
          <el-option v-for="(item, index) in deviceList" :key="index" :label="item.fDeviceName"
            :value="item.fId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="客户内码">
        <el-select v-loadmore="clientLoad" filterable clearable v-model="queryParams.fClientName" placeholder="请选择"
          @change="queryParams.pageNum = 1, getList()">
          <el-option v-for="(item, index) in clientList" :key="index" :label="item.fClientCode"
            :value="item.fId"></el-option>
        </el-select>
      </el-form-item>
      <br />
      <el-form-item label="负责人">
        <el-select v-loadmore="userLoad" filterable clearable v-model="queryParams.fUserId" placeholder="请选择"
          @change="queryParams.pageNum = 1, getList()">
          <el-option v-for="(item, index) in userList" :key="index" :label="item.nickName"
            :value="item.userId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="结果状态">
        <el-select v-model="queryParams.fResultApproveState" clearable placeholder="请选择" style="width: 240px"
          @change="queryParams.pageNum = 1, getList()">
          <el-option v-for="(item, index) in dict.type.wf_result_state" :key="index" :label="item.label"
            :value="item.value"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="日期">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="选择开始日期" end-placeholder="选择结束日期" @change="dateChange"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" type="index" width="50"></el-table-column>
      <el-table-column label="工单号" prop="fOrderNo" align="center" class-name="small-padding fixed-width" />
      <el-table-column label="工单名称" prop="fOrderName" align="center" class-name="small-padding fixed-width" />
      <el-table-column label="工单类型" prop="fOrderType" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <span>{{ scope.row.fOrderType == 0 ? '质检单' : '波形调试' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="负责人" prop="sysUser.nickName" align="center" class-name="small-padding fixed-width" />
      <el-table-column label="结果状态" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <span>{{ scope.row.fResultApproveState === 0 ? '人工待确认' : scope.row.fResultApproveState === 1
            ? '结果待提交' : scope.row.fResultApproveState === 2 ? '结果待审核' : scope.row.fResultApproveState ===
              3 ? '结果被拒绝' : scope.row.fResultApproveState ===
                4 ? '测试完成' : '' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="OK/NG次数" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <span>{{ scope.row.wfTestResultState.ok + '/' + scope.row.wfTestResultState.ng }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工厂名称" prop="bcmOrg.fOrgName" align="center" class-name="small-padding fixed-width" />
      <el-table-column label="设备名称" prop="wfDevice.fDeviceName" align="center" class-name="small-padding fixed-width" />
      <el-table-column label="产品名称" prop="bcmProduct.fProductName" align="center"
        class-name="small-padding fixed-width" />
      <el-table-column label="模组类型" prop="bcmProduct.fModuleType" align="center"
        class-name="small-padding fixed-width" />
      <el-table-column label="尺寸" prop="bcmProduct.fProductSize" align="center"
        class-name="small-padding fixed-width" />
      <el-table-column label="产品型号" prop="bcmProduct.fProductName" align="center"
        class-name="small-padding fixed-width" />
      <el-table-column label="客户内码" prop="bcmClient.fClientCode" align="center"
        class-name="small-padding fixed-width" />
      <el-table-column label="完成时间" prop="fEndTime" align="center" class-name="small-padding fixed-width" />
      <el-table-column fixed="right" label="操作" align="center" min-width="300" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row, 1)"
            v-hasPermi="['system:role:edit']">查看</el-button>

          <el-button v-if="scope.row.fResultApproveState == 0 || scope.row.fResultApproveState == 3" size="mini"
            type="text" icon="el-icon-edit" @click="handleUpdate(scope.row, 3)"
            v-hasPermi="['system:edit']">人工确认结果</el-button>

          <el-button v-if="scope.row.fResultApproveState == 1" size="mini" type="text" icon="el-icon-edit"
            @click="handleSubmit(scope.row)" v-hasPermi="['system:edit']">结果提交</el-button>

          <el-button v-if="scope.row.fResultApproveState == 2" size="mini" type="text" icon="el-icon-edit"
            @click="handleaudit(scope.row, 2)" v-hasPermi="['system:edit']">结果审核</el-button>

        </template>
      </el-table-column>
      <!--波形调试工单的查看  -->
      <el-dialog :visible.sync="dialoge1" append-to-body width="60%">
        <el-form ref="form" :model="form">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">结果详情（波形调试）</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-form-item prop="configName">
            <el-row :gutter="20">
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单号">{{ form.fOrderNo }}</el-form-item>
                  <el-form-item label="工单类型">
                    {{ form.fOrderType == 0 ? '质检单' : '波形调试' }}
                  </el-form-item>
                  <el-form-item label="负责人">{{ form.sysUser == undefined ? "" : form.sysUser.nickName }}
                  </el-form-item>
                  <el-form-item label="尺寸">{{ form.bcmProduct == undefined ? "" : form.bcmProduct.fProductSize }}
                  </el-form-item>
                  <el-form-item label="结果审核人">{{ form.fApproverName }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="MES工单号">{{
                    form.fMesNo
                  }}
                  </el-form-item>
                  <el-form-item label="工厂名称">{{ form.bcmOrg == undefined ? "" : form.bcmOrg.fOrgName }}
                  </el-form-item>
                  <el-form-item label="产 品">{{
                    form.bcmProduct == undefined ? "" : form.bcmProduct.fProductName
                  }}
                  </el-form-item>
                  <el-form-item label="产品批次号">{{ form.fProductBatchNo }}</el-form-item>
                  <el-form-item label="结果审核时间">{{ form.fApproveDate }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单优先级">
                    {{
                      form.fOrderPriority === 0 ? '紧急' :
                        form.fOrderPriority === 1 ? '高' :
                          form.fOrderPriority === 2 ? '中' :
                            form.fOrderPriority === 3 ? '低' :
                              ''
                    }}
                  </el-form-item>
                  <el-form-item label="模组类型：">
                    {{ form.bcmProduct == undefined ? "" : form.bcmProduct.fModuleType }}
                  </el-form-item>
                  <el-form-item label="设备名称">{{ form.wfDevice == undefined ? "" : form.wfDevice.fDeviceName }}
                  </el-form-item>
                  <el-form-item label="托盘规格">{{ form.fTraySpecofocatopns }}</el-form-item>
                  <el-form-item label="完成时间">{{ form.fEndTime }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单名称">{{ form.fOrderName }}</el-form-item>
                  <el-form-item label="客户内码">{{ form.bcmClient == undefined ? "" : form.bcmClient.fClientCode }}
                  </el-form-item>
                  <el-form-item label="产品型号">
                    {{ form.bcmProduct == undefined ? "" : form.bcmProduct.fDeviceModel }}
                  </el-form-item>
                  <el-form-item label="交付日期">{{ form.fPayDate }}</el-form-item>
                  <el-form-item label="创建日期">{{ form.fCreateDate }}</el-form-item>
                </div>
              </el-col>
            </el-row>
          </el-form-item>
          <br>
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">任务信息</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-form-item label="测试结果" prop="createBy">
            <el-select v-model.number="form.fOrderRunNum" placeholder="请选择测试结果" clearable style="width: 240px"
              @change="handleChange">
              <el-option v-for="(item, index) in csList" :key="index" :label="'第' + item + '次测试'"
                :value="item"></el-option>
            </el-select>
          </el-form-item>
          <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <el-tab-pane label="测试任务" name="first">
              <el-table v-loading="loading" :data="wfOrderTaskListResultList" style="width: 100%">
                <el-table-column label="编码" prop="fTaskId" align="center" width="100"></el-table-column>
                <<el-table-column label="任务名称" prop="fTaskName" :show-overflow-tooltip="true" align="center"
                  min-width="200" />
                <el-table-column label="调试任务类型" prop="fTaskType" :show-overflow-tooltip="true" align="center"
                  min-width="200">
                  <template slot-scope="scope">
                    <span>{{
                      scope.row.fTaskType === 0 ? '质检任务'
                        : scope.row.fTaskType === 1 ? '预调试VS_R任务'
                          : scope.row.fTaskType === 2 ? '预调试VS_W任务'
                            : scope.row.fTaskType === 3 ? 'LAB值调试任务'
                              : scope.row.fTaskType === 4 ? '动态波形调试任务'
                                : '' }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="温度段" prop="fHeatStageCollection" :show-overflow-tooltip="true" align="center"
                  min-width="200" />
                <el-table-column label="期待LAB范围值" align="center">
                  <el-table-column label="B" min-width="100" align="center">
                    <template slot-scope="scope">
                      <div>{{
                        formatLabRangeValue(scope.row)
                      }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="W" min-width="100" align="center">
                    <template slot-scope="scope">
                      <div>{{
                        formatLabRangeValue(scope.row)
                      }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="R" min-width="100" align="center">
                    <template slot-scope="scope">
                      <div>{{
                        formatLabRangeValue(scope.row)
                      }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="Y" min-width="100" align="center">
                    <template slot-scope="scope">
                      <div>{{
                        formatLabRangeValue(scope.row)
                      }}</div>
                    </template>
                  </el-table-column>
                </el-table-column>
                <el-table-column label="温箱总静置时间(分钟)" prop="fQuietMinuteCollection" :show-overflow-tooltip="true"
                  align="center" min-width="200" />
                <el-table-column label="测试总托盘数" prop="fTextNumCollection" :show-overflow-tooltip="true" align="center"
                  min-width="200">
                  <template slot-scope="scope">
                    <div>{{ formatTextNumCollection(scope.row) }}</div>
                  </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="showDialog2(scope.row)">查看
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="VS 数值" name="third">
              <el-table style="width:100%;" :data="form.wfPlanDetailList" ref="wfPlanDetail">
                <el-table-column label="VS_W 预设数值" align="center">
                  <el-table-column label="序号" align="center" type="index" width="150"></el-table-column>
                  <el-table-column label="温度（℃）" prop="fHeatStage" align="center"
                    class-name="small-padding fixed-width" />
                  <el-table-column label="VS_W 数值" prop="fVs" align="center" class-name="small-padding fixed-width" />
                </el-table-column>
              </el-table>
              <br>
              <el-table style="width:100%;" :data="form.wfPlanDetailLists" ref="wfPlanDetail">
                <el-table-column label="VS_R 预设数值" align="center">
                  <el-table-column label="序号" type="index" width="150" align="center"></el-table-column>
                  <el-table-column label="温度（℃）" prop="fHeatStage" align="center"
                    class-name="small-padding fixed-width" />
                  <el-table-column label="VS_R 数值" prop="fVs" align="center" class-name="small-padding fixed-width" />
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="测试记录" name="second">
              <el-timeline :reverse="true">
                <el-timeline-item v-for="(record, index) in form.wfTestResultLogList" :key="index"
                  :timestamp="record.fCreateDate">
                  {{ record.resultLog }}
                </el-timeline-item>
              </el-timeline>
            </el-tab-pane>
          </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="adopt" v-if="isEdit == 2">通 过</el-button>
          <el-button type="primary" @click="testConfirm" v-if="isEdit == 3">确认结果</el-button>
          <el-button type="danger" @click="refuse" v-if="isEdit == 2">拒 绝</el-button>
          <el-button @click="dialoge1 = false">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 任务查看 -->
      <el-dialog :visible.sync="dialoge2" append-to-body width="60%">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">任务查看</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple-dark">
                <el-form-item label="预调试类型">
                  <template slot-scope="scope">
                    <span>{{
                      debugging === 0 ? '质检任务'
                        : debugging === 1 ? '预调试VS_R任务'
                          : debugging === 2 ? '预调试VS_W任务'
                            : debugging === 3 ? 'LAB值调试任务'
                              : debugging === 4 ? '动态波形调试任务'
                                : '' }}</span>
                  </template>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple-dark">
                <el-form-item label="任务名称"> {{ Taskname }}</el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-table v-loading="loading" :data="wfTestResultLists" style="width: 100%">
            <el-table-column label="编号" type="index" width="120" />
            <el-table-column label="温度段" prop="fHeatStage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="波形名称" prop="wfWaveForm.fWaveName" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="最大电压(V)" prop="fMaxVoltage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="最小电压(V)" prop="fMinVoltage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="间隔电压(V)" prop="fIntervalVoltage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="刷新图片" prop="fPictureUrl" width="200" align="center">
              <template slot-scope="scope">
                <el-link @click="uploadFile(scope.$index)" :underline="false" target="_blank">
                  <span class="el-icon-document"> {{ scope.row.fPictureUrl ?
                    getFileName(scope.row.fPictureUrl) : '' }} </span>
                </el-link>
                <a style="color: #2561EF;" target="_blank" :download="getFileName(scope.row.fPictureUrl)"
                  :href="scope.row.fPictureUrl" :name="getFileName(scope.row.fPictureUrl)">下载</a>
                <!-- <el-link :underline="false" @click="handleDownload(scope.$index)">下载</el-link> -->
              </template>
            </el-table-column>
            <el-table-column label="温箱总静置时间(分钟)" prop="fQuietMinute" :show-overflow-tooltip="true" align="center"
              min-width="200" />
            <el-table-column label="驱动板等待时间(秒)" prop="wfDriverWait.fDriverWaitTime" :show-overflow-tooltip="true"
              align="center" width="210" />
            <el-table-column label="并行开关" prop="fHeatStage" width="200" :show-overflow-tooltip="true" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.fHeatStage == 0 ? '开启' : '关闭' }}</span>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit" @click="showDialog8(scope.row)">查看
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialoge2 = false">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 测试完成页 -->
      <el-dialog :visible.sync="dialoge8" append-to-body width="60%">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">结果详情</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple-dark">
                <el-form-item label="最佳VS_R值:"> {{ optimum }}</el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-table v-loading="loading" :data="wfTestResultListw" style="width: 100%">
            <el-table-column label="编号" type="index" width="120" />]
            <el-table-column label="托盘编码" prop="fBoardQr" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="嵌入式板编码" prop="fEpaperQr" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="波形" prop="wfWaveForm.fWaveName" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="温度(℃)" prop="fHeatStage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="电压" prop="fVoltage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="结果图片" :show-overflow-tooltip="true" align="center">
              <template slot-scope="scope">
                <!-- <el-image :src="scope.row.fPictureUrl" style="width: 50px; height: 50px;"
                        :preview-src-list="[`${scope.row.fPictureUrl}`]" fit="cover" append-to-body
                        preview-teleported="true" alt="暂无图片"></el-image> -->
                <img :src="scope.row.fPictureUrl" @click="handlePictureCardPreview(scope.row.fPictureUrl)"
                  style="width: 50px;height: 50px;" alt="">
              </template>
            </el-table-column>
            <el-table-column label="B" align="center">
              <el-table-column prop="fBlackLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fBlackANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fBlackBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="W" align="center">
              <el-table-column prop="fWhiteLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fWhiteANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fWhiteBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="R" align="center">
              <el-table-column prop="fRedLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fRedANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fRedBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="Y" align="center">
              <el-table-column prop="fYellowLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fYellowANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fYellowBNum" label="B" width="50"></el-table-column>
            </el-table-column>
          </el-table>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialoge8 = false">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 成功完成页 -->
      <el-dialog :visible.sync="dialoge3" append-to-body width="80%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-form-item prop="configName">
            <div class="flex">
              <div class="w-20" style="font-size: 16px;font-weight: 600;">动态波形调试任务结果</div>
              <div
                style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
              </div>
            </div>
            <br>
            <el-col :span="24">
              <div class="grid-content bg-purple-dark">
                <el-form-item label="任务名称：">20240507波形调试</el-form-item>
              </div>
            </el-col>
            <el-col :span="12">
              <el-form-item label="温度段(最小)">10</el-form-item>
              <el-form-item label="VS值">10</el-form-item>
              <el-form-item label="温箱静置时间">10</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="温度段(最大)">20</el-form-item>
              <el-form-item label="VCOM值">10</el-form-item>
              <el-form-item label="测试托盘数">10</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="期望LAB值范围"></el-form-item>
              <el-form-item label="红"></el-form-item>
              <el-form-item label="黑"></el-form-item>
              <el-form-item label="白"></el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="图片">
              </el-form-item>
            </el-col>
          </el-form-item>
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">任务流程</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialoge3 = false">取 消</el-button>
        </div>
      </el-dialog>

      <!--质检工单的查看  -->
      <el-dialog :visible.sync="dialoge4" width="80%" append-to-body>
        <el-form ref="form" :model="form">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">结果详情（质检单）</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-form-item prop="configName">
            <el-row :gutter="20">
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单号">{{ form.fOrderNo }}</el-form-item>
                  <el-form-item label="工单类型">
                    {{ form.fOrderType == 0 ? '质检单' : '波形调试' }}
                  </el-form-item>
                  <el-form-item label="负责人">{{ form.sysUser == undefined ? "" : form.sysUser.nickName }}
                  </el-form-item>
                  <el-form-item label="尺寸">{{ form.bcmProduct == undefined ? "" : form.bcmProduct.fProductSize }}
                  </el-form-item>
                  <el-form-item label="结果审核人">{{ form.fApproverName }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="MES工单号">{{
                    form.fMesNo
                  }}
                  </el-form-item>
                  <el-form-item label="工厂名称">{{ form.bcmOrg == undefined ? "" : form.bcmOrg.fOrgName }}
                  </el-form-item>
                  <el-form-item label="产 品">{{
                    form.bcmProduct == undefined ? "" : form.bcmProduct.fProductName
                  }}
                  </el-form-item>
                  <el-form-item label="产品批次号">{{ form.fProductBatchNo }}</el-form-item>
                  <el-form-item label="结果审核时间">{{ form.fApproveDate }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单优先级">
                    {{
                      form.fOrderPriority === 0 ? '紧急' :
                        form.fOrderPriority === 1 ? '高' :
                          form.fOrderPriority === 2 ? '中' :
                            form.fOrderPriority === 3 ? '低' :
                              ''
                    }}
                  </el-form-item>
                  <el-form-item label="模组类型：">
                    {{ form.bcmProduct == undefined ? "" : form.bcmProduct.fModuleType }}
                  </el-form-item>
                  <el-form-item label="设备名称">{{ form.wfDevice == undefined ? "" : form.wfDevice.fDeviceName }}
                  </el-form-item>
                  <el-form-item label="托盘规格">{{ form.fTraySpecofocatopns }}</el-form-item>
                  <el-form-item label="完成时间">{{ form.fEndTime }}</el-form-item>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple">
                  <el-form-item label="工单名称">{{ form.fOrderName }}</el-form-item>
                  <el-form-item label="客户内码">{{ form.bcmClient == undefined ? "" : form.bcmClient.fClientCode }}
                  </el-form-item>
                  <el-form-item label="产品型号">
                    {{ form.bcmProduct == undefined ? "" : form.bcmProduct.fDeviceModel }}
                  </el-form-item>
                  <el-form-item label="交付日期">{{ form.fPayDate }}</el-form-item>
                  <el-form-item label="创建日期">{{ form.fCreateDate }}</el-form-item>
                </div>
              </el-col>
            </el-row>
          </el-form-item>
          <br>
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">任务信息</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-form-item label="测试结果" prop="createBy">
            <el-select v-model.number="form.fOrderRunNum" placeholder="请选择测试结果" clearable style="width: 240px"
              @change="handleChange">
              <el-option v-for="(item, index) in csList" :key="index" :label="'第' + item + '次测试'"
                :value="item"></el-option>
            </el-select>
          </el-form-item>
          <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <el-tab-pane label="测试任务" name="first">
              <el-table v-loading="loading" :data="wfOrderTaskListResultList" style="width: 100%">
                <el-table-column label="编码" prop="fTaskId" align="center" width="100"></el-table-column>
                <el-table-column label="任务名称" prop="fTaskName" :show-overflow-tooltip="true" align="center" />
                <el-table-column label="任务状态" prop="fState" :show-overflow-tooltip="true" align="center">
                  <template slot-scope="scope">
                    <div>{{ scope.row.fState == 0 ? 'OK' : 'NG' }}</div>
                  </template>
                </el-table-column>
                <el-table-column label="温度段" prop="fHeatStageCollection" :show-overflow-tooltip="true" align="center" />
                <el-table-column label="温箱静置时间(分钟)" prop="fQuietMinuteCollection" :show-overflow-tooltip="true"
                  align="center" />
                <el-table-column label="测试样品总数量" prop="fTextNumCollection" :show-overflow-tooltip="true"
                  align="center" />
                <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="showDialog5(scope.row)">查看
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="测试记录" name="second">
              <el-timeline :reverse="true">
                <el-timeline-item v-for="(record, index) in form.wfTestResultLogList" :key="index"
                  :timestamp="record.fCreateDate">
                  {{ record.resultLog }}
                </el-timeline-item>
              </el-timeline>
            </el-tab-pane>
            <el-tab-pane label="审批流程" name="third">
              <el-timeline>
                <el-timeline-item v-for="(activity, index) in form.wfOrderApproveProcessList" :key="index"
                  :icon="activity.icon"
                  :type="activity.fDocumentStatus === 0 ? 'primary' : activity.fDocumentStatus === 1 ? 'success' : activity.fDocumentStatus === 2 ? 'danger' : ''"
                  size="large" :timestamp="activity.fApproveDate">
                  <!-- <template slot-scope="scope"> -->
                  <span>{{
                    activity.fDocumentStatus === 0 ? '发起申请' :
                      activity.fDocumentStatus === 1 ? '审核通过' :
                        activity.fDocumentStatus === 2 ? '审核拒绝' :
                          '' }}</span>
                  <!-- </template> -->
                  <br>
                  {{ activity.fApproverName }}
                </el-timeline-item>
              </el-timeline>
            </el-tab-pane>
          </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="adopt" v-if="isEdit == 2">通 过</el-button>
          <el-button type="primary" @click="testConfirm" v-if="isEdit == 3">确认结果</el-button>
          <el-button type="danger" @click="refuse" v-if="isEdit == 2">拒 绝</el-button>
          <el-button @click="dialoge4 = false">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 质检测试详情 -->
      <el-dialog :visible.sync="dialoge5" append-to-body width="80%">
        <el-form ref="form" :model="form" :rules="rules" label-width="10-`0px">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">质检测试详情</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-table v-loading="loading" :data="wfTestResultList" style="width: 100%" height="500">
            <el-table-column label="编号" type="index" width="120" />
            <el-table-column label="子任务名称" prop="fTasjName" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="托盘编码" prop="fBoardQr" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="嵌入式板编码" prop="fEpaperQr" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="送样日期" prop="fStartTime" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="温度段" prop="fHeatStage" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="结果图片" :show-overflow-tooltip="true" align="center">
              <template slot-scope="scope">
                <!-- <el-image :src="scope.row.fPictureUrl" style="width: 50px; height: 50px;"
                        :preview-src-list="[`${scope.row.fPictureUrl}`]" fit="cover" append-to-body
                        preview-teleported="true" alt="暂无图片"></el-image> -->
                <img :src="scope.row.fPictureUrl" @click="handlePictureCardPreview(scope.row.fPictureUrl)"
                  style="width: 50px;height: 50px;" alt="">
              </template>
            </el-table-column>
            <el-table-column label="B" align="center">
              <el-table-column prop="fBlackLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fBlackANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fBlackBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="W" align="center">
              <el-table-column prop="fWhiteLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fWhiteANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fWhiteBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="R" align="center">
              <el-table-column prop="fRedLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fRedANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fRedBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="Y" align="center">
              <el-table-column prop="fYellowLNum" label="L" width="50"></el-table-column>
              <el-table-column prop="fYellowANum" label="A" width="50"></el-table-column>
              <el-table-column prop="fYellowBNum" label="B" width="50"></el-table-column>
            </el-table-column>
            <el-table-column label="期待LAB范围值" align="center">
              <el-table-column v-for="(item, index) in dict.type.wf_module_color"
                :key="`${item.value}-${index}-${item.label}`" :label="item.label" width="50">
                <template slot-scope="scope">
                  <div v-for="(itemL, indexL) in scope.row.bcmClientPreset.bcmClientPresetDetailList"
                    :key="`${itemL.fEntryId}-${item.label}-${indexL}`" v-if="itemL.fColor == item.value">{{ itemL.fLMin
                    }}-{{ itemL.fLMax }}</div>
                  <div v-for="(itemA, indexA) in scope.row.bcmClientPreset.bcmClientPresetDetailList"
                    :key="`${item.label}-${indexA}-${itemA.fEntryId}`" v-if="itemA.fColor == item.value">{{ itemA.fAMin
                    }}-{{ itemA.fAMax }}</div>
                  <div v-for="(itemB, indexB) in scope.row.bcmClientPreset.bcmClientPresetDetailList"
                    :key="`${indexB}-${itemB.fEntryId}-${item.label}`" v-if="itemB.fColor == item.value">{{ itemB.fBMin
                    }}-{{ itemB.fBMax }}</div>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="最终测试结果" prop="fState" :show-overflow-tooltip="true" align="center">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.wf_task_state" :value="scope.row.fState"></dict-tag>
              </template>
            </el-table-column>
            <el-table-column label="LAB值测试结果" align="center">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.wf_task_state" :value="scope.row.fDeviceState"></dict-tag>
              </template>
            </el-table-column>
            <el-table-column label="残影测试最终结果" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.fIsShadow == 1">{{ scope.row.fDeviceState === 0 ? 'OK' : 'NG' }}</span>
              </template>
            </el-table-column>
            <el-table-column label="测试项目" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.fIsShadow == 1">{{ scope.row.fTestProject === 0 ? '标准残影检测' : 'NA-B残影检测' }}</span>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="LAB人工确认" align="center" class-name="small-padding fixed-width"
              min-width="100" v-if="isEdit != 1">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit" @click="handleOK(scope.row)"
                  v-if="isEdit != 1">OK</el-button>
                <el-button size="mini" type="text" icon="el-icon-edit" @click="handleNG(scope.row)"
                  v-if="isEdit != 1">NG</el-button>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="残影测试" align="center" class-name="small-padding fixed-width"
              min-width="100">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit" @click="showDialog6(scope.row)"
                  v-if="scope.row.fIsShadow == 1">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
          <br>
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">任务测试数据统计</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-tabs v-model="activeNames" type="card" @tab-click="handleClick">
            <el-tab-pane label="LAB值分布图" name="first">
              <el-select v-model.number="chartType" placeholder="请选择测试结果" clearable style="width: 240px"
                @change="chartChange">
                <el-option v-for="(item, index) in chartList" :key="index" :label="item.label"
                  :value="item.value"></el-option>
              </el-select>
              <div ref="charts" style="width: 1200px;height: 200px;">
              </div>
            </el-tab-pane>
            <el-tab-pane label="OK/NG状况图" name="second">OK/NG状况图
              <div ref="chartsBar" style="width: 800px;height: 200px;">
              </div>
            </el-tab-pane>
          </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialoge5 = false">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 测试结果 -->
      <el-dialog :visible.sync="dialoge6" append-to-body width="60%" @close="closeDialog">
        <el-form ref="testResult" :model="testResult" :rules="rules" label-width="150px">
          <div class="flex">
            <div class="w-20" style="font-size: 16px;font-weight: 600;">标准残影检测</div>
            <div
              style="vertical-align: middle;text-align: right;display: inline-block;width: 100%;border-top: 1px solid #ccc;margin-top:10px">
            </div>
          </div>
          <br>
          <el-form-item prop="configName">
            <el-row :gutter="20">
              <el-col :span="10">
                <div class="grid-content bg-purple">
                  <el-form-item label="残影测试最终结果">{{ testResult.fShadowState == 0 ? 'OK' : 'NG' }}</el-form-item>
                  <el-form-item label="标准整图">
                    <img class="el-upload-list__item-thumbnail"
                      @click="handlePictureCardPreview(testResult.fCriterionPictureUrl)"
                      style="width: 200px;height: 200px;" :src="testResult.fCriterionPictureUrl" alt="">
                    <!-- <el-image :src="testResult.fCriterionPictureUrl" style="width: 200px; height: 200px;"
                        :preview-src-list="[`${testResult.fCriterionPictureUrl}`]" fit="cover" append-to-body
                        preview-teleported="true" alt="暂无图片"></el-image> -->
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="10">
                <div class="grid-content bg-purple">
                  <el-form-item label="设备最终结果">{{ testResult.fDeviceState == 0 ? 'OK' : 'NG' }}</el-form-item>
                  <el-form-item label="测试整图">
                    <img class="el-upload-list__item-thumbnail"
                      @click="handlePictureCardPreview(testResult.fDevicePictureUrl)"
                      style="width: 200px;height: 200px;" :src="testResult.fDevicePictureUrl" alt="">
                    <!-- <el-image :src="testResult.fDevicePictureUrl" style="width: 200px; height: 200px;"
                        :preview-src-list="[`${testResult.fDevicePictureUrl}`]" fit="cover" append-to-body
                        preview-teleported="true" alt="暂无图片"></el-image> -->
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
          </el-form-item>
          比对结果确认
          <el-divider></el-divider>
          <el-form ref="form" :model="form">
            <el-table v-loading="loading" :data="testResult.wfContrastResult" style="width: 100%">
              <el-table-column label="序号" type="index" width="120" />
              <el-table-column label="服务器比对结果" prop="roleName" :show-overflow-tooltip="true" align="center">
                <template slot-scope="scope">
                  <div>{{ scope.row.fState == 0 ? 'OK' : scope.row.fState == 1 ? 'NG' : '--' }}</div>
                </template>
              </el-table-column>
              <el-table-column label="人工确认结果" prop="fUserState" :show-overflow-tooltip="true" align="center">
                <template slot-scope="scope">
                  <div>{{ scope.row.fUserState == 0 ? 'OK' : scope.row.fUserState == 1 ? 'NG' : '--' }}</div>
                </template>
              </el-table-column>
              <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width"
                min-width="100" v-if="isEdit != 1">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleOKPut(scope.row)"
                    v-if="isEdit != 1">OK</el-button>
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleNGPut(scope.row)"
                    v-if="isEdit != 1">NG</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-form>
          <br>
          <el-form ref="testResult" :model="testResult">
            <el-form-item>屏整体不良现象
              <el-checkbox-group v-model="testResult.screenBadIds" @change="handleBadScreen" :disabled="isEdit == 1">
                <el-checkbox :label="item.value" :value="item.value" :key="item.index"
                  v-for="(item, index) in dict.type.screen_bad">{{ item.label }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-form>
          <br>
          <el-form ref="testResult" :model="testResult">
            <el-form-item>字体不良现象
              <el-checkbox-group v-model="testResult.wordBadIds" @change="handleBad" :disabled="isEdit == 1">
                <el-checkbox :label="item.value" :value="item.value" :key="item.index"
                  v-for="(item, index) in dict.type.word_bad">{{ item.label }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-form>
        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addBad()" v-if="isEdit != 1">保 存</el-button>
          <el-button @click="dialoge6 = false">取 消</el-button>
        </div>
      </el-dialog>

    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <el-dialog :visible.sync="dialogVisible" title="预览" width="800" append-to-body>
      <img :src="dialogImageUrl" style="display: block; max-width: 100%; margin: 0 auto" />
    </el-dialog>
  </div>
</template>

<script>
import { listOrg } from "@/api/basicData/factory"
import { listDevice } from "@/api/basicData/equipment"
import { listClient } from "@/api/basicData/customer"
import { listUser } from "@/api/system/user"
import {
  listOrderTest,
  getOrderTest,
  delOrderTest,
  addOrderTest,
  listTestResulst,
  listTestResultw,
  updateOrderTest, listTestResult, listTests, contrastResult, contrastResultPut, addBad, statequality, testConfirm
} from "@/api/testResult/testResultData";
// import VueCropper from 'vue-cropper'
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
export default {
  // components: {
  //   VueCropper
  // },
  name: "TestResultData",
  dicts: ['wf_order_type', 'wf_order_priority', 'wf_task_state', 'screen_bad', 'word_bad', 'wf_result_state', 'wf_module_color'],
  data() {
    return {
      debugging: '',
      Taskname: '',
      optimum: '',
      // imageSrc: '',
      // cropBoxData: { 
      //   x: 0,-
      //   y: 0,
      //   width: 100,
      //   height: 100
      // },
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false,
      isEdit: 0,
      dialoge1: false,
      dialoge2: false,
      dialoge3: false,
      dialoge4: false,
      dialoge5: false,
      dialoge6: false,
      dialoge8: false,
      tableData: [],
      checkList: [],
      dateRange: "",
      activeName: "first",
      activeNames: "first",
      lineChartData: "",
      wostsa: "",
      // 遮罩层
      loading: true,
      // 选中数组 
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公告表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 岗位表格数据
      postList: [],
      //测试任务
      wfOrderTaskListResultList: [
        {
          fId: "",
          fTaskName: '',
          fState: '',
          fHeatStage: '',
          roleKey: '',
          fQuietMinute: ''
        },
      ],
      wfPlanDetailList: [],
      wfPlanDetailLists: [],
      wfVsSettingList: [],
      //质检测试详情
      wfTestResultList: [],
      wfTestResultLists: [],
      wfTestResultListw: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 30,

      },
      testResult: {
        fDevicePictureUrl: '',
        fCriterionPictureUrl: '',
        fShadowState: 0,
        fDeviceState: 0
      },
      // 表单参数
      form: {
        sysUser: {
          nickName: '',
        },
        bcmProduct: {
          fProductSize: '',
        },
        bcmOrg: {
          fOrgName: '',
        },
        wfDevice: {},
        bcmClient: {},
        wfOrderTaskList: [
          {
            fLogicalSettings: 0,
            fEndTestNum: ''
          }
        ],
      },
      // 表单校验
      rules: {
        noticeTitle: [
          { required: true, message: "公告标题不能为空", trigger: "blur" }
        ],
        noticeType: [
          { required: true, message: "公告类型不能为空", trigger: "change" }
        ]
      },
      activities: {
        fDocumentStatus: {},
        fApproverName: '',
        fApproveDate: '',
      },
      //排序
      reverse: true,
      testRecords: [
        {
          content: '测试用例编写完成',
          timestamp: '2023-07-01'
        },
        {
          content: '第一轮测试开始',
          timestamp: '2023-07-05'
        },
        {
          content: '第一轮测试发现 5 个问题',
          timestamp: '2023-07-10'
        },
        {
          content: '问题修复完成，开始第二轮测试',
          timestamp: '2023-07-15'
        },
        {
          content: '第二轮测试通过',
          timestamp: '2023-07-20'
        }
      ],
      csList: [],
      pieChart: null,
      chartType: 0,
      chartList: [
        {
          label: 'B',
          value: 0
        },
        {
          label: 'W',
          value: 1
        },
        {
          label: 'R',
          value: 2
        },
        {
          label: 'Y',
          value: 3
        }
      ],
      chartObj: {},
      chartObjs: {},
      wfScreenBadList: [],
      wfWordBadList: [],
      fId: '',
      factoryWhere: { pageNum: 1, pageSize: 20 },
      deviceWhere: { pageNum: 1, pageSize: 20 },
      clientWhere: { pageNum: 1, pageSize: 20 },
      userWhere: { pageNum: 1, pageSize: 20 },
      factoryList: [],
      deviceList: [],
      clientList: [],
      userList: [],
    };
  },
  created() {
    this.getFactory()
    this.getDevice()
    this.getClient()
    this.getUser()
    this.getList();
  },
  methods: {
    uploadFile(index) {
      this.imgIndex = index;
      this.showUploadImg = true
    },
    getFileName(name) {
      // 如果是url那么取最后的名字 如果不是直接返回
      if (name.lastIndexOf("/") > -1) {
        return name.slice(name.lastIndexOf("/") + 1);
      } else {
        return name;
      }
    },
    formatTextNumCollection(row) {
      if (row.fTaskType && row.fTaskType === 1) {
        return '--';
      }
      if (row.fTaskType && row.fTaskType === 2) {
        return '--';
      }
      return row.fTextNumCollection;
    },
    formatLabRangeValue(row) {
      if (!row.bcmClientPreset) {
        return '--';
      }
      const { fBlackLMin, fBlackAMin, fBlackAMax, fBlackBMin, fBlackBMax, fWhiteLMin, fWhiteAMin, fWhiteAMax, fWhiteBMin, fWhiteBMax, fRedLMin, fRedAMin, fRedAMax, fRedBMin, fRedBMax, fYellowLMin, fYellowAMin, fYellowAMax, fYellowBMin, fYellowBMax } = row.bcmClientPreset;
      return `B: L:${fBlackLMin}-${fBlackLMin},A:${fBlackAMin}-${fBlackAMax},B:${fBlackBMin}-${fBlackBMax}; W: L:${fWhiteLMin}-${fWhiteLMin},A:${fWhiteAMin}-${fWhiteAMax},B:${fWhiteBMin}-${fWhiteBMax}; R: L:${fRedLMin}-${fRedLMin},A:${fRedAMin}-${fRedAMax},B:${fRedBMin}-${fRedBMax}; Y: L:${fYellowLMin}-${fYellowLMin},A:${fYellowAMin}-${fYellowAMax},B:${fYellowBMin}-${fYellowBMax}`;
    },
    dateChange(e) {
      console.log(e)
      this.queryParams.fCreateDateStart = e[0]
      this.queryParams.fCreateDateEnd = e[1]
      this.getList()
    },
    getFactory() {
      listOrg(this.factoryWhere).then(res => {
        this.factoryList = [...this.factoryList, ...res.rows]
      })
    },
    getDevice() {
      listDevice(this.deviceWhere).then(res => {
        this.deviceList = [...this.deviceList, ...res.rows]
      })
    },
    getClient() {
      listClient(this.clientWhere).then(res => {
        this.clientList = [...this.clientList, ...res.rows]
      })
    },
    getUser() {
      listUser(this.userWhere).then(res => {
        this.userList = [...this.userList, ...res.rows]
      })
    },
    factoryLoad() {
      this.factoryWhere.pageNum += 1
      this.getFactory()
    },
    deviceLoad() {
      this.deviceWhere.pageNum += 1
      this.getDevice()
    },
    clientLoad() {
      this.clientWhere.pageNum += 1
      this.getClient()
    },
    userLoad() {
      this.userWhere.pageNum += 1
      this.getUser()
    },
    handleClick(e) {

    },
    chartChange(e) {
      if (e == 0) {
        let obj = {
          fHeatStage: [],
          fANum: [],
          fBNum: [],
          fLNum: []
        }
        if (this.chartObj.wfTestResultBLabList && this.chartObj.wfTestResultBLabList.length > 0) {
          this.chartObj.wfTestResultBLabList.map((item) => {
            obj.fHeatStage.push(item.fHeatStage)
            obj.fANum.push(item.fANum)
            obj.fBNum.push(item.fBNum)
            obj.fLNum.push(item.fLNum)
          });
        }
        this.getChar(obj)
      } else if (e == 1) {
        let obj = {
          fHeatStage: [],
          fANum: [],
          fBNum: [],
          fLNum: []
        }
        if (this.chartObj.wfTestResultWLabList && this.chartObj.wfTestResultWLabList.length > 0) {
          this.chartObj.wfTestResultWLabList.map((item) => {
            obj.fHeatStage.push(item.fHeatStage)
            obj.fANum.push(item.fANum)
            obj.fBNum.push(item.fBNum)
            obj.fLNum.push(item.fLNum)
          });
        }
        this.getChar(obj)
      } else if (e == 2) {
        let obj = {
          fHeatStage: [],
          fANum: [],
          fBNum: [],
          fLNum: []
        }
        if (this.chartObj.wfTestResultRLabList && this.chartObj.wfTestResultRLabList.length > 0) {
          this.chartObj.wfTestResultRLabList.map((item) => {
            obj.fHeatStage.push(item.fHeatStage)
            obj.fANum.push(item.fANum)
            obj.fBNum.push(item.fBNum)
            obj.fLNum.push(item.fLNum)
          });
        }
        this.getChar(obj)
      } else if (e == 3) {
        let obj = {
          fHeatStage: [],
          fANum: [],
          fBNum: [],
          fLNum: []
        }
        if (this.chartObj.wfTestResultYLabList && this.chartObj.wfTestResultYLabList.length > 0) {
          this.chartObj.wfTestResultYLabList.map((item) => {
            obj.fHeatStage.push(item.fHeatStage)
            obj.fANum.push(item.fANum)
            obj.fBNum.push(item.fBNum)
            obj.fLNum.push(item.fLNum)
          });
        }
        this.getChar(obj)
      }
    },
    getChar(obj) {
      const pieDom1 = this.$refs.charts
      this.pieChart = echarts.init(pieDom1);
      var option;
      option = {
        // title: {
        //   text: 'Stacked Line'
        // }, 
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['L值', 'A值', 'B值']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: obj.fHeatStage
        },
        yAxis: {
          type: 'value',
          min: -140,
          max: 140,
          splitNumber: 4,
          interval: 140 / 2,
        },
        series: [
          {
            name: 'L值',
            type: 'line',
            stack: 'Total',
            barWidth: '20%',
            data: obj.fLNum
          },
          {
            name: 'A值',
            type: 'line',
            stack: 'Total',
            barWidth: '20%',
            data: obj.fANum
          },
          {
            name: 'B值',
            type: 'line',
            stack: 'Total',
            barWidth: '20%',
            data: obj.fBNum
          }
        ]
      };
      option && this.pieChart.setOption(option);
    },
    getCharBar(obj) {
      const pieDom1 = this.$refs.chartsBar
      this.pieChartBar = echarts.init(pieDom1);
      var option;
      option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          data: ['OK', 'NG']
        },
        xAxis: [
          {
            type: 'category',
            axisTick: { show: false },
            data: obj.fHeatStage
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: 'OK',
            type: 'bar',
            barGap: 0,
            emphasis: {
              focus: 'series'
            },
            data: obj.ok
          },
          {
            name: 'NG',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: obj.ng
          }
        ]
      };
      option && this.pieChartBar.setOption(option);
    },
    getcontrastResult(row, state) {
      var data = {
        fId: row.fEntryId,
        fState: row.fState,
        fUserState: state
      }
      contrastResult(data).then(res => {
        this.testRecords = res.data
        listTestResult(this.queryParams).then(response => {
          this.wfTestResultList = response.rows;
          this.wfTestResultLists = response.rows;
          this.total = response.total;
        });
      })
    },
    handleChange(e) {
      console.log(e);
      const query = {
        fId: this.form.fId,
        fOrderRunNum: e,
        fOrderNo: this.form.fOrderNo
      }
      getOrderTest(query).then(response => {
        this.loading = false
        this.form = response.data
        this.form.fOrderType = this.form.fOrderType + ''
        this.wfOrderTaskListResultList = response.data.wfOrderTaskListResultList;
      })
      listTests(this.form.fId).then(res => {
        this.csList = res.data;
      })
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    },

    // handleCrop(data) {
    //   // 处理裁剪结果
    //   this.cropBoxData = data;
    // },
    // uploadImage() {
    //   // 获取裁剪后的图片
    //   this.$refs.cropper.getCroppedCanvas().toBlob(blob => {
    //     // 创建FormData并上传
    //     let formData = new FormData();
    //     formData.append('image', blob, 'image.jpg');

    //     // 这里使用axios作为请求库，你可以根据实际情况替换为你的请求库
    //     axios.post('/upload', formData, {
    //       headers: {
    //         'Content-Type': 'multipart/form-data'
    //       }
    //     }).then(response => {
    //       // 处理上传成功的响应
    //       console.log(response.data);
    //     }).catch(error => {
    //       // 处理上传失败的情况
    //       console.error(error);
    //     });
    //   });
    // },

    /** 查询公告列表 */
    getList() {
      this.loading = true;
      listOrderTest(this.queryParams).then(response => {
        this.postList = response.rows;
        this.total = response.total;
        this.loading = false;
      });


    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      },
        this.dateRange = ''
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    //  波形调试工单的查看
    showDialog1() {
      console.log('点击了选项 1');
      this.dialoge1 = true;
    },
    showDialog2(row) {
      console.log('点击了选项 1');
      this.queryParams.fResultId = []
      this.queryParams.fEntryId = row.fEntryId
      this.debugging = row.fTaskType
      this.Taskname = row.fTaskName
      listTestResulst(this.queryParams).then(response => {
        this.wfTestResultLists = response.rows;
        this.total = response.total;
        this.dialoge2 = true;
      });
    },
    showDialog8(row) {
      console.log('点击了选项 1');
      this.chartObj = row
      this.queryParams.fEntryId = row.fEntryId
      this.optimum = row.fBestVoltage
      listTestResultw(this.queryParams).then(response => {
        this.wfTestResultListw = response.rows;
        this.total = response.total;
        this.dialoge8 = true;
      })
    },
    showDialog3() {
      console.log('点击了选项 1');
      this.dialoge3 = true;
    },

    //质检工单的查看
    showDialog4() {
      console.log('showDialog4 方法被调用');
      this.dialoge4 = true;
    },
    showDialog5(row) {
      console.log('点击了选项 1');
      this.chartObj = row
      this.queryParams.fEntryId = []
      this.queryParams.fResultId = row.fResultId
      listTestResult(this.queryParams).then(response => {
        this.wfTestResultList = response.rows;
        this.total = response.total;
        this.dialoge5 = true;
        this.$nextTick(() => {
          let obj = {
            fHeatStage: [],
            fANum: [],
            fBNum: [],
            fLNum: []
          }
          if (this.chartObj.wfTestResultBLabList && this.chartObj.wfTestResultBLabList.length > 0) {
            this.chartObj.wfTestResultBLabList.map((item) => {
              obj.fHeatStage.push(item.fHeatStage)
              obj.fANum.push(item.fANum)
              obj.fBNum.push(item.fBNum)
              obj.fLNum.push(item.fLNum)
            });
          }
          this.getChar(obj)
          let bar = {
            fHeatStage: [],
            ng: [],
            ok: []
          }
          if (this.chartObj.wfTestResultStateList && this.chartObj.wfTestResultStateList.length > 0) {
            this.chartObj.wfTestResultStateList.map((item) => {
              bar.fHeatStage.push(item.fHeatStage)
              bar.ng.push(item.ng)
              bar.ok.push(item.ok)
            });
          }
          this.getCharBar(bar)
        });
      });

    },
    closeDialog() {
      this.dialoge6 = false;
      this.dialoge5 = false;

    },
    showDialog6(row) {
      this.testResult = row
      if (!this.testResult.screenBadIds) {
        this.testResult.screenBadIds = []
      } else {
        this.testResult.screenBadIds = JSON.parse(this.testResult.screenBadIds)
      }
      if (!this.testResult.wordBadIds) {
        this.testResult.wordBadIds = []
      } else {
        this.testResult.wordBadIds = JSON.parse(this.testResult.wordBadIds)
      }
      this.wfScreenBadList = {
        fId: row.fEntryId,
        fBadId: this.testResult.screenBadIds
      }
      this.wfWordBadList = {
        fId: row.fEntryId,
        fBadId: this.testResult.wordBadIds
      }
      this.dialoge6 = true;
    },
    // 查看
    handleUpdate(row, type) {
      this.isEdit = type
      if (row.fOrderType == '0') {
        this.dialoge4 = true
      } else {
        this.dialoge1 = true
      }
      this.loading = true
      this.reset()
      const query = {
        fId: row.fId,
        fOrderNo: row.fOrderNo

      }
      getOrderTest(query).then(response => {
        this.loading = false
        this.form = response.data
        this.form.fOrderType = this.form.fOrderType + ''
        this.wfOrderTaskListResultList = response.data.wfOrderTaskListResultList;
        this.open = true
        this.form.wfPlanDetailList = [];
        this.form.wfPlanDetailLists = [];
        if (response.data.fVsRSetting === 1 || response.data.fVsWSetting === 1) {
          response.data.wfVsSettingList.forEach(element => {
            if (element.fVsType === 0) {
              this.form.wfPlanDetailList.push(element);
            }
            if (element.fVsType === 1) {
              this.form.wfPlanDetailLists.push(element);
            }
          });
        }
      })
      listTests(row.fId).then(res => {
        this.csList = res.data;
      })
    },
    //取消
    handleOK(row) {
      this.getcontrastResult(row, 0)
    },
    //取消
    handleNG(row) {
      this.getcontrastResult(row, 1)
    },
    handleOKPut(row) {
      this.getcontrastResultPut(row, 0)
    },
    //取消
    handleNGPut(row) {
      this.getcontrastResultPut(row, 1)
    },
    getcontrastResultPut(row, state) {
      var data = {
        fId: row.fEntryId,
        fState: row.fState,
        fUserState: state
      }
      contrastResultPut(data).then(res => {
        this.testRecords = res.data
        // listTestResult(this.queryParams).then(response => {
        //   this.wfTestResultList = response.rows;
        //   this.total = response.total;
        // });
      })
    },
    handleBadScreen(e) {
      let obj = {
        fId: this.testResult.fEntryId,
        fBadId: []
      }
      if (e && e.length > 0) {
        e.map((item) => {
          obj.fBadId.push(item);
        });
      }
      console.log(obj)
      this.wfScreenBadList = obj
    },
    handleBad(e) {
      console.log(e)
      let obj = {
        fId: this.testResult.fEntryId,
        fBadId: []
      }
      if (e && e.length > 0) {
        e.map((item) => {
          obj.fBadId.push(item);
        });
      }
      console.log(obj)
      this.wfWordBadList = obj
    },
    addBad() {
      if (this.wfScreenBadList.fBadId.length < 1) {
        return this.$message({ message: '请选择屏整体不良现象', type: 'warning' })
      }
      if (this.wfWordBadList.fBadId.length < 1) {
        return this.$message({ message: '请选择字体不良现象', type: 'warning' })
      }
      let data = {
        fEntryId: this.testResult.fEntryId,
        wfScreenBad: this.wfScreenBadList,
        wfWordBad: this.wfWordBadList
      }

      addBad(data).then(res => {
        this.$message({ message: '提交成功', type: 'success' })
        this.wfScreenBadList = []
        this.wfWordBadList = []
        this.dialoge6 = false
        this.dialoge5 = false
      })
    },

    testConfirm() {
      const data = {
        fId: this.form.fId,
        fDocumentStatus: 1
      }
      this.$modal.confirm('是否要【确认】质检结果？确认后结果将不可更改。').then(function () {
        testConfirm(data).then(res => {
          this.$message.success('提交成功');
          this.dialoge1 = false
          this.dialoge4 = false
        }
        )
      }).then(() => {
        this.$message.success('提交成功');
        this.dialoge1 = false
        this.dialoge4 = false
      }).catch(() => { })
    },
    adopt() {
      const data = {
        fId: this.form.fId,
        fDocumentStatus: 1
      }
      statequality(data).then(res => {
        this.$message.success('提交成功');
        this.dialoge1 = false
        this.dialoge4 = false
      })
    },
    refuse() {
      const data = {
        fId: this.form.fId,
        fDocumentStatus: 2
      }
      statequality(data).then(res => {
        this.$message.success('提交成功');
        this.dialoge1 = false
        this.dialoge4 = false
      })
    },
    //提交
    handleSubmit(row) {
      const data = {
        fId: row.fId || this.ids,
        fDocumentStatus: 0
      }
      statequality(data).then(res => {
        this.$message.success('提交成功');
        this.dialoge1 = false
        this.dialoge4 = false
      })
    },
    //审核
    handleaudit(row, type) {
      this.isEdit = type
      this.fId = row.fId
      if (row.fOrderType == '0') {
        this.dialoge1 = true
      } else {
        this.dialoge4 = true
      }
      this.loading = true
      this.reset()
      const query = {
        fId: row.fId,
        fOrderNo: row.fOrderNo,
        fOrderRunNum: row.fOrderRunNum
      }
      getOrderTest(query).then(response => {
        this.loading = false
        this.form = response.data
        this.form.fOrderType = this.form.fOrderType + ''
        this.wfOrderTaskListResultList = response.data.wfOrderTaskListResultList;
        this.open = true
      })
      listTests(row.fId).then(res => {
        this.csList = res.data;
      })
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.noticeId != undefined) {
            updateOrderTest(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrderTest(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const noticeIds = row.noticeId || this.ids
      this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项？').then(function () {
        return delOrderTest(noticeIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
  },

};
</script>
